GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

report-auto-complete.js ➔ onResponse   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
c 0
b 0
f 0
dl 0
loc 11
rs 10
1
(function ( $ ) {
2
  'use strict';
3
4
  $.fn.extend({
5
    reportAutoComplete: function ()
6
    {
7
      $(this).each(function(idx, el) {
8
        var element = $(el);
9
        var criteriaName = element
10
            .data('criteria-name');
11
        var choiceName = element
12
            .data('choice-name');
13
        var choiceValue = element
14
            .data('choice-value');
15
        var autocompleteValue = element
16
            .find('input.autocomplete')
17
            .val();
18
        var loadForEditUrl = element
19
            .data('load-edit-url');
20
21
        element
22
            .dropdown({
23
              delay: {
24
                search: 250
25
              },
26
              minCharacters: 3,
27
              forceSelection: false,
28
              apiSettings: {
29
                dataType: 'JSON',
30
                cache: false,
31
                beforeSend: function beforeSend(settings) {
32
                  /* eslint-disable-next-line no-param-reassign */
33
                  settings.data[criteriaName] = settings.urlData.query;
34
35
                  return settings;
36
                },
37
                onResponse: function onResponse(response) {
38
                  return {
39
                    success: true,
40
                    results: response.map(function (item) {
41
                      return {
42
                        name: item[choiceName],
43
                        value: item[choiceValue]
44
                      };
45
                    })
46
                  };
47
                }
48
              }
49
            });
50
51
        if (autocompleteValue.split(',')
52
            .filter(String).length > 0) {
53
          var menuElement = element
54
              .find('div.menu');
55
56
          menuElement.api({
57
            on: 'now',
58
            method: 'GET',
59
            url: loadForEditUrl,
60
            beforeSend: function beforeSend(settings) {
61
              /* eslint-disable-next-line no-param-reassign */
62
              settings.data[choiceValue] = autocompleteValue.split(',')
63
                  .filter(String);
64
65
              return settings;
66
            },
67
            onSuccess: function onSuccess(response) {
68
              response.forEach(function (item) {
69
                menuElement.append($('<div class="item" data-value="' + item[choiceValue] + '">' + item[choiceName] + '</div>'));
70
              });
71
            }
72
          });
73
        }
74
75
        window.setTimeout(function () {
76
          element
77
              .dropdown('set selected', element
78
                  .find('input.autocomplete')
79
                  .val()
80
                  .split(',')
81
                  .filter(String));
82
        }, 5000);
83
      });
84
    }
85
  });
86
})(jQuery);
87